(function(){
    
    let navBool=false;
    let shop='';
    let area='';
    let Null='';
    let state=1;
    let shopid=0;
    let areaid=0;
    $.ajax({
        url:"http://chst.vip:1234/api/getgsshop"
    }).then( res=>{
        res.result.forEach(item => {
            shop+=`
                <li id="${item.shopId}">${item.shopName}</li>
            `
        });

    }).then(
        function(){
            $.ajax({
                url:"http://chst.vip:1234/api/getgsproduct",
                data:{
                    shopid,
                    areaid
                }
            }).then( res=>{
                let html="";
                res.result.forEach(item => {
                    html+=`
                    <li>
                    <a href="#">
                        <img src="${item.productImg}" alt="">
                    <div class="title">
                    ${item.productName}
                    </div>
                    <div class="price">${item.productPrice}</div>
                    </a>
                    </li>
                    `
                })
                $(".product").html(html)
               
        
            })
        }).then(function(){
            // console.log(shop);
            $.ajax({
                url:"http://chst.vip:1234/api/getgsshoparea"
            }).then( res=>{
                res.result.forEach(item => {
                    area+=`
                        <li id="${item.areaId}">${item.areaName}</li>
                    `
                });
    
        }).then(function(){
            
            // console.log(area);
            $(".shop").on("click",function(e){
                navBool=!navBool;
                // console.log(navBool);
                if(navBool){
                    $(".form").html(shop)
                    state=0;
                    // update();
                    
    
                }else{
                    $(".form").html(Null)
                }
            })
            $(".place").on("click",function(e){
                navBool=!navBool;
                // console.log(navBool);
                if(navBool){
                    $(".form").html(area)
                    state=1
                    // update()
                    
                }else{
                    $(".form").html(Null)
                }
            })
        }).then(function(){


            $(".form").on("click","li",function(e){
                let id=$(this).attr("id")
                let text=$(this).html()
                let html=`
                <span >${text}</span>
                <span>▼</span>
                `
                if(state==0){
                    shopid=id;
                    let html=`
    
                <a shopid="${id}/">
                     <span >${text}</span>
                    <span>▼</span>
                </a>
                `
                    $(".shop").html(html)
                }else{
                    areaid=id;
                    text=text.split("（");
                    // console.log(text);
                    let html=`
                    <a areaid="${id}">
                    <span>${text[0]}</span>
                    <span>▼</span>
                </a>
                `
                    $(".place").html(html)
                }
    
                $(".form").html(Null)
                navBool=false;
            
                $.ajax({
                    url:"http://chst.vip:1234/api/getgsproduct",
                    data:{
                        shopid,
                        areaid
                    }
                }).then( res=>{
                    let html="";
                    res.result.forEach(item => {
                        html+=`
                        <li>
                        <a href="#">
                            <img src="${item.productImg}" alt="">
                        <div class="title">
                        ${item.productName}
                        </div>
                        <div class="price">${item.productPrice}</div>
                        </a>
                        </li>
                        `
                    })
                    $(".product").html(html)
                   
            
                })
                
            })
           
            

        })
    })
    
    

    function render(id,text){
        return new Promise(function (resolve, reject) {
            
            
           
            
           
            
        }) 
    }
}())
function A(){
    let num = 1
    return function B(){

    } 
}
let c = B().num
console.log(c);
